<%@page import="java.sql.Statement"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.PreparedStatement"%>
<%@page import="java.sql.Connection"%>
<%@page import="com.mysql.jdbc.Driver"%>
<%@page import="java.sql.DriverManager"%>

<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>List Guestbook</title>
</head>
<body>

	<%
		Connection conn = null;
		PreparedStatement pstmt = null;
		DriverManager.registerDriver(new com.mysql.jdbc.Driver());
		//Class.forName("com.mysql.jdbc.Driver"); Connection
		conn = DriverManager.getConnection("jdbc:mysql://j.snpy.org/j102",
				"jstu", "abc123");
		String sql = "select id, userid, nickname, title from guestbook";
		pstmt = conn.prepareStatement(sql);
		ResultSet rs = pstmt.executeQuery();
	%>

	<table border="1">
		<%
		while (rs.next()) {
		%>
		<tr>
		<%
		int id = rs.getInt("id");
		String userid = rs.getString("userid");
		String nickname = rs.getString("nickname");
		String title = rs.getString("title");
		out.println("	<td>" + id + "</td>");
		out.println("	<td>" + userid + "</td>");
		out.println("	<td>" + nickname + "</td>");
		out.println("	<td>" + title + "</td>");	
		%>
		<td><a href="delete_post.jsp?id=?">刪除</a></td>

		</tr>
		<%
		}
		%>

	</table>

</body>
</html>